#include <cstdio>

struct Node
{
    Node *p, *l, *r;
    int size, a, revmark;
    Node( ) { p = l = r = NULL; size = 1; revmark = 0; }
}*root;

void update( Node *x )
{
    x->size = 1;
    if ( x->l ) x->size += x->l->size;
    if ( x->r ) x->size += x->r->size;
}

void reverse( Node *x )
{
    Node *y = x->l;
    x->l = x->r;
    x->r = y;
    x->revmark ^= 1;
}

void down( Node *x )
{
    if ( x->revmark )
    {
        if ( x->l ) reverse( x->l );
        if ( x->r ) reverse( x->r );
        x->revmark = 0;
    }
}

void zig( Node *x )
{
    Node *y = x->p;
    down( y ); down( x );
    y->l = x->r; if ( x->r ) x->r->p = y;
    x->r = y; x->p = y->p;
    if ( y->p )
        if ( y->p->l == y ) y->p->l = x;
        else y->p->r = x;
    y->p = x;
    if ( y == root ) root = x;
    update( y );
}

void zag( Node *x )
{
    Node *y = x->p;
    down( y ); down( x );
    y->r = x->l; if ( x->l ) x->l->p = y;
    x->l = y; x->p = y->p;
    if ( y->p )
        if ( y->p->l == y ) y->p->l = x;
        else y->p->r = x;
    y->p = x;
    if ( y == root ) root = x;
    update( y );
}

void splay( Node *x, Node *f )
{
    Node *y;
    down( x );
    while ( x->p != f )
    {
        y = x->p;
        if ( y->p == f )
            if ( y->l == x )
                zig( x );
            else
                zag( x );
        else
            if ( y->p->l == y )
                if ( y->l == x )
                    zig( y ), zig( x );
                else
                    zag( x ), zig( x );
            else
                if ( y->r == x )
                    zag( y ), zag( x );
                else
                    zig( x ), zag( x );
    }
    update( x );
}

void select( int k, Node *f )
{
    Node *p = root;
    int s;
    while ( 1 )
    {
        down( p );
        if ( p->l ) s = p->l->size;
        else s = 0;
        if ( k == s + 1 ) break;
        if ( k <= s ) p = p->l;
        else { p = p->r; k -= s + 1; }
    }
    splay( p, f );
}

int n, m;
bool flag;

void print( Node *p )
{
    int i;
    down( p );
    if ( p->l ) print( p->l );
    if ( p->a >= 1 && p->a <= n )
    {
        if ( flag ) printf(" ");
        else flag = true;
        printf("%d", p->a);
    }
    if ( p->r ) print( p->r );
}

int main( )
{
    int i, a, b, c;
    Node *p;
    char cmd[ 10 ];
    while ( scanf("%d%d", &n, &m) )
    {
        if ( n == -1 && m == -1 )
            break;
        root = new Node;
        root->a = 0;
        for ( i = 1; i <= n + 1; i++ )
        {
            select( i, NULL );
            p = new Node;
            p->a = i;
            root->r = p;
            p->p = root;
            splay( p, NULL );
            select( 1, NULL );
        }
        while ( m-- )
        {
            scanf("%s", cmd);
            if ( cmd[ 0 ] == 'C' )
            {
                scanf("%d%d%d", &a, &b, &c);
                select( a, NULL );
                select( b + 2, root );
                p = root->r->l;
                root->r->l = NULL;
                update( root->r );
                update( root );
                select( c + 1, NULL );
                select( c + 2, root );
                root->r->l = p;
                p->p = root->r;
                update( root->r );
                update( root );
            }
            else
            {
                scanf("%d%d", &a, &b);
                select( a, NULL );
                select( b + 2, root );
                reverse( root->r->l );
            }
        }
        flag = false;
        print( root );
        printf("\n");
    }
    return 0;
}
